<?php
	/**
 	 * System settings class
 	 */
	class SystemSettingsController extends Controller
	{
		public $page_title = LANG_SYSTEM_SETTINGS;
		public $layout = 'main';
		public $module = 'administration';
		public $helpers = array ('html', 'htmlx', 'toolbars', 'grids|index');
		public $name = 'systemsettings';
		public $menuItem = 'systemsettings';
		
		/**
		 * Gets system settings list
		 */		
		function index()
		{
			$this->data[$this->name] = $this->controller_model->ListItems(array('sort_by'=>$this->request->get[sort_by], 'sort_method'=>$this->request->get[sort_method]), 'sp_system_settings_list');
		}
		
		/**
		 * Edits existing system setting
		 *
		 * @param bigint $id system setting id
		 */		
		function edit($id)
		{
			$this->data[$this->name] = $this->controller_model->Get($id);			
			if (!empty($this->request->post))
			{
				
				if ($this->controller_model->Update($this->request->post))
				{
					$this->Redirect($this->name);
				}
				else
				{
					$this->data[$this->name] = $this->request->post;				
				}
			}
			else
			{

			}	
		}
		
		/**
		 * View an existing system setting
		 *
		 * @param bigint $id system setting id
		 */		
		function view($id)
		{
			$this->data[$this->name] = $this->controller_model->Get($id);
		}
				
		/**
		 * Add a system setting
		 */	
		function add()
		{
			
			if (!empty($this->request->post))
			{				
				if ($this->controller_model->Update($this->request->post))
				{
					$this->Redirect($this->name);
				}
				else
				{
					$this->data[$this->name] = $this->request->post;				
				}
			}
			else
			{	

			}	
		}
	}
?>